package md.lanjing.com.module_wallet.contact;

import android.content.Context;

import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.util.ToastUtils;



import com.lxh.baselibray.constant.Constant;

import md.lanjing.com.module_wallet.R;
import md.lanjing.com.module_wallet.api.WalletApiService;
import md.lanjing.com.module_wallet.bean.ExchangeRecordResponce;
import md.lanjing.com.module_wallet.bean.RecordRequest;
import retrofit2.Call;
import retrofit2.Response;

public class ExchangeRecordContact {
    public static class ExchangeRecordPresent extends BasePresent<IExchangeRecordView> {
        public void queryRecordList(final Context context, int pageNo){
            WalletApiService service= ServiceGenerator.createService(WalletApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            RecordRequest request=new RecordRequest(userId,pageNo);
            service.exChangeRecord(request).enqueue(new NetCallBack<ExchangeRecordResponce>() {
                @Override
                public void onSuccess(Call<ExchangeRecordResponce> call, Response<ExchangeRecordResponce> response) {
                    if (getView()!=null){
                        getView().getRecordListData(response);
                    }
                }

                @Override
                public void onFailed() {
                    ToastUtils.showLongToast(context,context.getString(R.string.request_failed));
                }
            });
        }
    }
    public interface IExchangeRecordView extends IBaseView {
        void getRecordListData(Response<ExchangeRecordResponce> response);
    }
}
